
 
 /**
  * 1.需求:点击扫码登录 log2 ,显示二维码 modal-4,添加样式log
  *        点击账号登录 log1 ,显示二维码 modal-3,添加样式log
  */
 
  let log1 = document.querySelector('.modal-2 #log1')
  let log2 = document.querySelector('.modal-2 #log2')
  let modal3 = document.querySelector('.modal3')
  let modal4 = document.querySelector('.modal4')
 let index = 0;
 log1.addEventListener('click',function () {
     //console.log(1);
     log2.className = ''
     this.className = 'log'
     modal3.style.display= "block"
     modal4.style.display= "none"
 
 })
 log2.addEventListener('click',function () {
     //console.log(2);
     log1.className = ''
     log2.className = 'log'
     modal4.style.display= "block"
     modal3.style.display= "none"
 
 })



/**
 * 2.需求:输入用户名id = user,失去焦点时, 判断输入的长度小于于6 ,显示提示userText
 *      输入密码id = pwd,失去焦点时, 判断输入的长度小于6,显示提示pwdText
 *      点击登录 submiteBtn ,判断
 * 事件:blur
 * 方法:test()
 */
 let user = document.querySelector('#user')
 let pwd = document.querySelector('#pwd')
 let submiteBtn = document.querySelector('#submiteBtn')

//1.定义规则
// let userReg = /^(13[0-9]|14[01456879]|15[0-3,5-9]|16[2567]|17[0-8]|18[0-9]|19[0-3,5-9])\d{8}$/
    
//1.定义规则
let userReg = /^\d{6}$/
let pwdReg = /^\d{6}$/


// let user = document.querySelector('#user')
// let pwd = document.querySelector('#pwd')

user.addEventListener('blur',function(){
    let bool = userReg.test(user.value);
    if(bool){
        userText.style.display = "none";
    }else{
        userText.style.display = "block";
        userText.textContent = '请输入六位数账号'
    }
})

pwd.addEventListener('blur',function(){
    // let pwdReg = /^\d{6}$/;
    let bool = pwdReg.test(pwd.value);
    if(bool){
        pwdText.style.display = "none";
    }else{
        pwdText.style.display = "block";
        pwdText.textContent = '请输入六位数密码'
    }
})


/**
 * 3.需求:点击登录 submiteBtn ,判断密码和账号是否输入正确
 */

 submiteBtn.addEventListener('click',function(){
    // console.log(1);
    // 判断
   if (!userReg.test(user.value)) {
       //如果为false shuchu
       userText.style.display = "block";
       userText.textContent = '账号错误!!!!!'
       
   }else if (!pwdReg.test(pwd.value)) {
       //pwdText.style.display = "block";
       pwdText.textContent = '密码错误!!!!!'

   }

})